"""
排序相关算法
"""
demolist = [1, 2, 3, 4, 5, 8, 9, 6, 7]


def bubblesort(l):
    print('冒泡排序前,l={}'.format(l))
    length = len(l)
    for i in range(length):
        for j in range(length - 1):
            if l[j] > l[j + 1]:
                temp = l[j]
                l[j] = l[j + 1]
                l[j + 1] = temp
    print('冒泡排序后,l={}'.format(l))

def bubblesort10():
    print('冒泡排序前,l={}'.format(demolist))
    length = len(demolist)
    for i in range(length):
        for j in range(length - 1):
            if demolist[j] > demolist[j + 1]:
                # temp = demolist[j]
                # demolist[j] = demolist[j + 1]
                # demolist[j + 1] = temp
                demolist[j], demolist[j+1] = demolist[j+1], demolist[j]
    print('冒泡排序后,l={}'.format(demolist))

if __name__ == "__main__":
    bubblesort10()
